package com.itheima.service.impl;

import com.itheima.dao.AccountDao;
import com.itheima.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.sql.DataSource;

@Service("AccountService")
public class AccountServiceImpl implements AccountService {
    @Autowired
    private AccountDao accountDao;

    @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.REPEATABLE_READ)
    public void transfer(String outMan, String inMan, double money) {//女性
        //开启事务,和提交事务给放到切片中,这样就不用每次都写开启和提交事务的代码了,这是一种抽取的思想
        accountDao.out(outMan,money);
//        int i = 1/0;
        accountDao.in(inMan,money);
    }

    @Transactional(isolation = Isolation.DEFAULT)
    public void xxx(){

    }

}
